import 'package:bilibili/pages/home/home_tabbar.dart';
import 'package:bilibili/pages/home/init_items.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:bilibili/core/extension/int_extension.dart';

class HomeScreen extends StatelessWidget {
  const HomeScreen({Key? key}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    return DefaultTabController(
      initialIndex: 1,
      length: 6,
      child: Scaffold(
        appBar: AppBar(
          title: buildContainer(),
          leading: GestureDetector(
              child: ClipOval(child: Image.network("https://i0.hdslb.com/bfs/face/member/noface.jpg@160w_160h_1c_1s.webp")),
              onTap: () {
                Navigator.of(context).pushNamed("/login");
              },
          ),
          bottom: HomeTabBar.buildTabBar(context),
        ),
        body: TabBarView(
          children: HomeItems.buildHomeItems(),
        ),
      ),
    );
  }

  Container buildContainer() {
    return Container(
          height: 60.px,
          child: TextField(
            cursorColor: Colors.pinkAccent,
            decoration: InputDecoration(
              icon: Icon(Icons.search, color: Colors.grey,),
              border: OutlineInputBorder(
                borderRadius: BorderRadius.circular(20.px),
                borderSide: BorderSide.none
              ),
              filled: true,
              fillColor: Color.fromARGB(255, 230, 230, 230)
            ),
          ),
        );
  }
}

